entry: Remove cursor adjustment APIs
authorBenjamin Otte <otte@redhat.com>
Mon, 26 Feb 2018 13:01:29 +0000 (14:01 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 2 Mar 2018 01:00:25 +0000 (02:00 +0100)
docs/reference/gtk/gtk4-sections.txt
gtk/gtkentry.c
gtk/gtkentry.h

index e5d867e536a4524bc4071b23dd8a4f4896e1b806..7ced016fcb03060bde566d67adca2cd444625099 100644 (file)
@@ -902,8 +902,6 @@ gtk_entry_set_attributes
 gtk_entry_get_attributes
 gtk_entry_set_completion
 gtk_entry_get_completion
-gtk_entry_set_cursor_hadjustment
-gtk_entry_get_cursor_hadjustment
 gtk_entry_set_progress_fraction
 gtk_entry_get_progress_fraction
 gtk_entry_set_progress_pulse_step
index c151ea7a716138cd721ee6278a19124ac89079d5..a098d28f6a99119b8747f6e6b502b4c088c341cd 100644 (file)
    (pos) == GTK_ENTRY_ICON_SECONDARY)
 
 static GQuark          quark_password_hint  = 0;
-static GQuark          quark_cursor_hadjustment = 0;
 static GQuark          quark_capslock_feedback = 0;
 static GQuark          quark_gtk_signal = 0;
 static GQuark          quark_entry_completion = 0;
@@ -608,7 +607,6 @@ static void         gtk_entry_grab_notify              (GtkWidget      *widget,
 static void         gtk_entry_check_cursor_blink       (GtkEntry       *entry);
 static void         gtk_entry_pend_cursor_blink        (GtkEntry       *entry);
 static void         gtk_entry_reset_blink_time         (GtkEntry       *entry);
-static void         gtk_entry_move_adjustments         (GtkEntry             *entry);
 static void         gtk_entry_update_cached_style_values(GtkEntry      *entry);
 static gboolean     get_middle_click_paste             (GtkEntry *entry);
 static void         gtk_entry_get_scroll_limits        (GtkEntry       *entry,
@@ -833,7 +831,6 @@ gtk_entry_class_init (GtkEntryClass *class)
   class->activate = gtk_entry_real_activate;
   
   quark_password_hint = g_quark_from_static_string ("gtk-entry-password-hint");
-  quark_cursor_hadjustment = g_quark_from_static_string ("gtk-hadjustment");
   quark_capslock_feedback = g_quark_from_static_string ("gtk-entry-capslock-feedback");
   quark_gtk_signal = g_quark_from_static_string ("gtk-signal");
   quark_entry_completion = g_quark_from_static_string ("gtk-entry-completion-key");
@@ -5421,7 +5418,6 @@ gtk_entry_set_positions (GtkEntry *entry,
 
   if (changed)
     {
-      gtk_entry_move_adjustments (entry);
       gtk_entry_recompute (entry);
     }
 }
@@ -6206,39 +6202,6 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
     }
 }
 
-static void
-gtk_entry_move_adjustments (GtkEntry *entry)
-{
-  GtkWidget *widget = GTK_WIDGET (entry);
-  GtkAdjustment *adjustment;
-  PangoContext *context;
-  PangoFontMetrics *metrics;
-  gint x, layout_x;
-  gint char_width;
-
-  adjustment = g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment);
-  if (!adjustment)
-    return;
-
-  /* Cursor/char position, layout offset and border width*/
-  gtk_entry_get_cursor_locations (entry, &x, NULL);
-  get_layout_position (entry, &layout_x, NULL);
-  x += layout_x;
-
-  /* Approximate width of a char, so user can see what is ahead/behind */
-  context = gtk_widget_get_pango_context (widget);
-
-  metrics = pango_context_get_metrics (context,
-                                       pango_context_get_font_description (context),
-                                      pango_context_get_language (context));
-  char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
-
-  /* Scroll it */
-  gtk_adjustment_clamp_page (adjustment, 
-                            x - (char_width + 1),   /* one char + one pixel before */
-                            x + (char_width + 2));  /* one char + cursor + one pixel after */
-}
-
 static gint
 gtk_entry_move_visually (GtkEntry *entry,
                         gint      start,
@@ -9191,55 +9154,6 @@ gtk_entry_get_completion (GtkEntry *entry)
   return completion;
 }
 
-/**
- * gtk_entry_set_cursor_hadjustment:
- * @entry: a #GtkEntry
- * @adjustment: (nullable): an adjustment which should be adjusted when the cursor
- *              is moved, or %NULL
- *
- * Hooks up an adjustment to the cursor position in an entry, so that when 
- * the cursor is moved, the adjustment is scrolled to show that position. 
- * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 
- * the adjustment.
- *
- * The adjustment has to be in pixel units and in the same coordinate system 
- * as the entry. 
- */
-void
-gtk_entry_set_cursor_hadjustment (GtkEntry      *entry,
-                                  GtkAdjustment *adjustment)
-{
-  g_return_if_fail (GTK_IS_ENTRY (entry));
-  if (adjustment)
-    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
-
-  if (adjustment)
-    g_object_ref (adjustment);
-
-  g_object_set_qdata_full (G_OBJECT (entry), 
-                           quark_cursor_hadjustment,
-                           adjustment, 
-                           g_object_unref);
-}
-
-/**
- * gtk_entry_get_cursor_hadjustment:
- * @entry: a #GtkEntry
- *
- * Retrieves the horizontal cursor adjustment for the entry. 
- * See gtk_entry_set_cursor_hadjustment().
- *
- * Returns: (transfer none) (nullable): the horizontal cursor adjustment, or %NULL
- *   if none has been set.
- */
-GtkAdjustment*
-gtk_entry_get_cursor_hadjustment (GtkEntry *entry)
-{
-  g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
-
-  return g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment);
-}
-
 static void
 gtk_entry_ensure_progress_widget (GtkEntry *entry)
 {
index a43f704e85ffed34a94bdefd32b37852e1a013e8..f68fe9eb082939e221a84b2fe696efff2b271a29 100644 (file)
@@ -250,14 +250,6 @@ GDK_AVAILABLE_IN_ALL
 gint       gtk_entry_text_index_to_layout_index (GtkEntry      *entry,
                                                  gint           text_index);
 
-/* For scrolling cursor appropriately
- */
-GDK_AVAILABLE_IN_ALL
-void           gtk_entry_set_cursor_hadjustment (GtkEntry      *entry,
-                                                 GtkAdjustment *adjustment);
-GDK_AVAILABLE_IN_ALL
-GtkAdjustment* gtk_entry_get_cursor_hadjustment (GtkEntry      *entry);
-
 /* Progress API
  */
 GDK_AVAILABLE_IN_ALL